package com.kangyi.admin.mapper;

import com.kangyi.admin.annotation.AutoFill;
import com.kangyi.dto.BannerDTO;
import com.kangyi.entity.Banner;
import com.kangyi.enumeration.OperationType;
import com.kangyi.vo.BannerListVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author Blank
 * @version 1.0
 */
@Mapper
public interface BannerMapper {

    @Select("select * from banner;")
    List<BannerListVO> listBanner();


    @Insert("insert into banner(image, sort, status, create_time, update_time, create_user, update_user) " +
            "values (#{image},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    @AutoFill(value = OperationType.INSERT)
    void addBanner(Banner banner);

    @Select("select * from banner where id = #{id};")
    Banner getById(Integer id);

    @Delete("delete from banner where id = #{id};")
    void deleteById(Integer id);

    @Update("update banner set status = #{status}, update_time = #{updateTime}, update_user = #{updateUser} where id = #{id};")
    @AutoFill(value = OperationType.UPDATE)
    void bulkOperation(Banner banner);

    @AutoFill(value = OperationType.UPDATE)
    void editBanner(Banner banner);

    @Select("select * from banner where sort = #{sort};")
    Banner getBySort(Integer sort);
}
